<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        li {
            list-style: none;
        }

        .li {
            /* display: inline-block; */
            float: left;
            margin-right: 100px;
        }
        .list{
            border: 1px solid black;   
            display: none; 
        }
        .hover{
            background-color: blanchedalmond;
            border-bottom: 2px solid blanchedalmond;
        }
    </style>
</head>

<body>
    <div>
        <div class="tab">
            <ul>
                <li class="li">
                    <ul>
                        <a>第一个标题</a>
                        <ul class="list">
                            <li>111</li>
                            <li>222</li>
                            <li>333</li>
                            <li>444</li>
                        </ul>
                    </ul>
                </li>
                <li class="li">
                    <ul>
                        <a>第二个标题</a>
                        <ul class="list">
                            <li>111</li>
                            <li>222</li>
                            <li>333</li>
                            <li>444</li>
                        </ul>

                    </ul>
                </li>
                <li class="li">
                    <ul>
                        <a>第三个标题</a>
                        <ul class="list">
                            <li>111</li>
                            <li>222</li>
                            <li>333</li>
                            <li>444</li>
                        </ul>
                    </ul>
                </li>
                <li class="li">
                    <ul>
                        <a>第四个标题</a>
                        <ul class="list">
                            <li>111</li>
                            <li>222</li>
                            <li>333</li>
                            <li>444</li>
                        </ul>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
    <script>
        let asli = document.querySelector('.tab').querySelectorAll('a');
        console.log(asli)
        for (let i = 0; i < asli.length; i++) {
            asli[i].addEventListener('mouseover', function () {
                this.setAttribute('class','hover')
                this.nextElementSibling.style.display = 'block'
            })
            asli[i].addEventListener('mouseout', function () {
                this.setAttribute('class','')
                this.nextElementSibling.style.display = 'none'
            })
        }
    </script>
</body>

</html>